#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn=2005;

int Sum(int a[], int start, int len)
{
    int i;
    int sum;
    len = start+len;
    for(i=start;i<len;i++)
    {
        sum+=a[i];
    }
    return sum;
}

int main()
{
    int n;
    int value[maxn];
    int i,len;
    int maxValue = -0x3f3f3f3f;
    int sum = 0;

    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> value[i];
        value[i+n] = value[i];
    }
    for(i=0;i<2*n;i++)
    {
        len = 1;
        if(len+i >= 2*n)
            break;
        sum = 0;
        while(len <= n)
        {
            sum = Sum(value, i, len);
            if(maxValue < sum)
                maxValue = sum;
            len++;
        }
    }
    cout >> maxValue;
}
